VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ANSI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'/******************************************************************/
'/*                                                                */
'/*                      TurboCAD for Windows                      */
'/*                   Copyright (c) 1993 - 2000                    */
'/*             International Microcomputer Software, Inc.         */
'/*                            (IMSI)                              */
'/*                      All rights reserved.                      */
'/*                                                                */
'/******************************************************************/

'DBAPI constants
Const gkGraphic = 11
Const gkArc = 2
Const gkText = 6
Const gfCosmetic = 128&

'Useful math constants
Const pi# = 3.14159265

'Real variant types!
Const typeEmpty = 0
Const typeInteger = 2
Const typeLong = 3
Const typeSingle = 4
Const typeDouble = 5
Const typeCurrency = 6
Const typeDate = 7
Const typeString = 8
Const typeObject = 9
Const typeBoolean = 11
Const typeVariant = 12
Const typeIntegerEnum = typeInteger + 100
Const typeLongEnum = typeLong + 100
Const typeStringEnum = typeString + 100

'Stock property pages
Const ppStockPen = 1
Const ppStockBrush = 2
Const ppStockText = 4
Const ppStockInsert = 8
Const ppStockViewport = 16
Const ppStockAuto = 32

'Property Ids
    ' Table-1
Const idImg11 = 11
Const idImg12 = 12
Const idImg13 = 13
Const idImg14 = 14
Const idImg15 = 15
Const idImg16 = 16
Const idImg17 = 17
Const idImg18 = 18

Const idImgFont11 = 51
Const idImgFont12 = 52
Const idImgFont13 = 53
Const idImgFont14 = 54
Const idImgFont15 = 55
Const idImgFont16 = 56
Const idImgFont17 = 57
Const idImgFont18 = 58

Const idTxt11 = 101
Const idTxt12 = 102
Const idTxt13 = 103
Const idTxt14 = 104
Const idTxt15 = 105

    ' Table-2
Const idImg21 = 21
Const idImg22 = 22
Const idImg23 = 23
Const idImg24 = 24
Const idImg25 = 25
Const idImg26 = 26
Const idImg27 = 27
Const idImg28 = 28

Const idImgFont21 = 61
Const idImgFont22 = 62
Const idImgFont23 = 63
Const idImgFont24 = 64
Const idImgFont25 = 65
Const idImgFont26 = 66
Const idImgFont27 = 67
Const idImgFont28 = 68

Const idTxt21 = 201
Const idTxt22 = 202
Const idTxt23 = 203
Const idTxt24 = 204
Const idTxt25 = 205

    ' Table-3
Const idImg31 = 31

Const idImgFont31 = 71

Const idTxt31 = 301

    ' Table-4
Const idTxt41 = 401

    ' Scale
Const idSymTxtHeight = 500
    
    ' Text Font
Const idTextFont = 501
    
    ' LinearUnitName
Const idUnitName = 502

'Property enums

'Number of properties, pages, wizards
Const NUM_PROPERTIES = 49
Const NUM_PAGES = 1
Const NUM_WIZARDS = 0

Private Sub Class_Initialize()
    'Initialize class variables
End Sub

'Returns the user-visible description of this RegenMethod
Public Property Get Description() As String
    Description = "Geometric Tolerance"
End Property

'Returns the persistent class id for this RegenMethod's property section
Public Property Get ClassID() As String
    ClassID = "{FDB6F1C4-9631-11d1-A40A-0000B465872B}"

End Property

'Retrieve types and names
Public Function GetPropertyInfo(Names As Variant, Types As Variant, _
    IDs As Variant, Defaults As Variant) As Long
    ReDim Names(NUM_PROPERTIES), Types(NUM_PROPERTIES), _
        IDs(NUM_PROPERTIES), Defaults(NUM_PROPERTIES)
        
'-----------------------------------------------------
'Begin Table-1
    Names(0) = "Image11"
    Types(0) = typeString
    IDs(0) = idImg11
    Defaults(0) = Chr(98)
    
    Names(1) = "Image12"
    Types(1) = typeString
    IDs(1) = idImg12
    Defaults(1) = Chr(110)
       
    Names(2) = "Image13"
    Types(2) = typeString
    IDs(2) = idImg13
    Defaults(2) = Chr(109)
        
    Names(3) = "Image14"
    Types(3) = typeString
    IDs(3) = idImg14
    Defaults(3) = ""
        
    Names(4) = "Image15"
    Types(4) = typeString
    IDs(4) = idImg15
    Defaults(4) = ""
        
    Names(5) = "Image16"
    Types(5) = typeString
    IDs(5) = idImg16
    Defaults(5) = ""
        
    Names(6) = "Image17"
    Types(6) = typeString
    IDs(6) = idImg17
    Defaults(6) = ""
        
    Names(7) = "Image18"
    Types(7) = typeString
    IDs(7) = idImg18
    Defaults(7) = ""
    
' Fonts for Imiges for the Table-1
    
    Names(30) = "ImageFont11"
    Types(30) = typeString
    IDs(30) = idImgFont11
    Defaults(30) = "gdt.shx"
    
    Names(31) = "ImageFont12"
    Types(31) = typeString
    IDs(31) = idImgFont12
    Defaults(31) = "gdt.shx"
       
    Names(32) = "ImageFont13"
    Types(32) = typeString
    IDs(32) = idImgFont13
    Defaults(32) = "gdt.shx"
        
    Names(33) = "ImageFont14"
    Types(33) = typeString
    IDs(33) = idImgFont14
    Defaults(33) = "gdt.shx"
        
    Names(34) = "ImageFont15"
    Types(34) = typeString
    IDs(34) = idImgFont15
    Defaults(34) = "gdt.shx"
        
    Names(35) = "ImageFont16"
    Types(35) = typeString
    IDs(35) = idImgFont16
    Defaults(35) = "gdt.shx"
        
    Names(36) = "ImageFont17"
    Types(36) = typeString
    IDs(36) = idImgFont17
    Defaults(36) = "gdt.shx"
        
    Names(37) = "ImageFont18"
    Types(37) = typeString
    IDs(37) = idImgFont18
    Defaults(37) = "gdt.shx"
    
' End fonts for images for the Table-1
    
    
        
    Names(8) = "Text11"
    Types(8) = typeString
    IDs(8) = idTxt11
    Defaults(8) = "0.000"
        
    Names(9) = "Text12"
    Types(9) = typeString
    IDs(9) = idTxt12
    Defaults(9) = ""
        
    Names(10) = "Text13"
    Types(10) = typeString
    IDs(10) = idTxt13
    Defaults(10) = "A"
       
    Names(11) = "Text14"
    Types(11) = typeString
    IDs(11) = idTxt14
    Defaults(11) = "B"
        
    Names(12) = "Text15"
    Types(12) = typeString
    IDs(12) = idTxt15
    Defaults(12) = "C"
'End Table-1
'-----------------------------------------------------------
        
'-----------------------------------------------------
'Begin Table-2
    Names(13) = "Image21"
    Types(13) = typeString
    IDs(13) = idImg21
    Defaults(13) = ""
    
    Names(14) = "Image22"
    Types(14) = typeString
    IDs(14) = idImg22
    Defaults(14) = ""
       
    Names(15) = "Image23"
    Types(15) = typeString
    IDs(15) = idImg23
    Defaults(15) = ""
        
    Names(16) = "Image24"
    Types(16) = typeString
    IDs(16) = idImg24
    Defaults(16) = ""
        
    Names(17) = "Image25"
    Types(17) = typeString
    IDs(17) = idImg25
    Defaults(17) = ""
        
    Names(18) = "Image26"
    Types(18) = typeString
    IDs(18) = idImg26
    Defaults(18) = ""
        
    Names(19) = "Image27"
    Types(19) = typeString
    IDs(19) = idImg27
    Defaults(19) = ""
        
    Names(20) = "Image28"
    Types(20) = typeString
    IDs(20) = idImg28
    Defaults(20) = ""
    
' Fonts for Imiges for the Table-2
    
    Names(38) = "ImageFont21"
    Types(38) = typeString
    IDs(38) = idImgFont21
    Defaults(38) = "gdt.shx"
    
    Names(39) = "ImageFont22"
    Types(39) = typeString
    IDs(39) = idImgFont22
    Defaults(39) = "gdt.shx"
       
    Names(40) = "ImageFont23"
    Types(40) = typeString
    IDs(40) = idImgFont23
    Defaults(40) = "gdt.shx"
        
    Names(41) = "ImageFont24"
    Types(41) = typeString
    IDs(41) = idImgFont24
    Defaults(41) = "gdt.shx"
        
    Names(42) = "ImageFont25"
    Types(42) = typeString
    IDs(42) = idImgFont25
    Defaults(42) = "gdt.shx"
        
    Names(43) = "ImageFont26"
    Types(43) = typeString
    IDs(43) = idImgFont26
    Defaults(43) = "gdt.shx"
        
    Names(44) = "ImageFont27"
    Types(44) = typeString
    IDs(44) = idImgFont27
    Defaults(44) = "gdt.shx"
        
    Names(45) = "ImageFont28"
    Types(45) = typeString
    IDs(45) = idImgFont28
    Defaults(45) = "gdt.shx"
    
' End fonts for images for the Table-2
        
    Names(21) = "Text21"
    Types(21) = typeString
    IDs(21) = idTxt21
    Defaults(21) = ""
        
    Names(22) = "Text22"
    Types(22) = typeString
    IDs(22) = idTxt22
    Defaults(22) = ""
        
    Names(23) = "Text23"
    Types(23) = typeString
    IDs(23) = idTxt23
    Defaults(23) = ""
       
    Names(24) = "Text24"
    Types(24) = typeString
    IDs(24) = idTxt24
    Defaults(24) = ""
        
    Names(25) = "Text25"
    Types(25) = typeString
    IDs(25) = idTxt25
    Defaults(25) = ""
    
'End Table-2
'-----------------------------------------------------------
        
        
'-----------------------------------------------------
'Begin Table-3
    Names(26) = "Image31"
    Types(26) = typeString
    IDs(26) = idImg31
    Defaults(26) = ""

' Fonts for Imiges for the Table-3
    
    Names(46) = "ImageFont31"
    Types(46) = typeString
    IDs(46) = idImgFont31
    Defaults(46) = "gdt.shx"
    
' End fonts for images for the Table-3
    
    Names(27) = "Text31"
    Types(27) = typeString
    IDs(27) = idTxt31
    Defaults(27) = ""
        
'End Table-3
'-----------------------------------------------------------
        
        
'-----------------------------------------------------
'Begin Table-4
    
    Names(28) = "Text41"
    Types(28) = typeString
    IDs(28) = idTxt41
    Defaults(28) = ""
        
'End Table-4
'-----------------------------------------------------------
        
 '-----------------------------------------------------
'Begin Scale
    
    Names(29) = "SymTxtHeight"
'    Types(29) = typeString
    Types(29) = typeDouble
    IDs(29) = idSymTxtHeight
'    Defaults(29) = "0.3"
    Defaults(29) = 0.3
        
'End Scale
'-----------------------------------------------------------
'Begin TextFont
    
    Names(47) = "FontTxt"
    Types(47) = typeString
    IDs(47) = idTextFont
    Defaults(47) = "Times New Roman"
        
'End TextFont

'Begin TextFont
    
    Names(48) = "UnitName"
    Types(48) = typeString
    IDs(48) = idUnitName
    Defaults(48) = "in"
        
'End TextFont

      
    GetPropertyInfo = NUM_PROPERTIES
End Function

'Get the number of property pages supporting this RegenMethod
Public Function GetPageInfo(ByVal AGraphic As Object, StockPages As Long, _
    Names As Variant) As Long
    ReDim Names(NUM_PAGES)

    'Need the form
    Load frmSample
    Names(0) = frmSample.Caption
    Unload frmSample

    StockPages = ppStockBrush + ppStockPen + ppStockAuto
    GetPageInfo = NUM_PAGES
End Function

Public Function GetWizardInfo(Names As Variant) As Long
    ReDim Names(NUM_WIZARDS)
    GetWizardInfo = NUM_WIZARDS
End Function

'Enumerate the names and values of a specified property
Public Function GetEnumNames(ByVal PropID As Long, Names As Variant, Values As Variant) As Long
    GetEnumNames = 0
End Function

Public Function PageControls(ByVal ThisRegenMethod As Object, ByVal theGraphic As Object, ByVal PageNumber As Long, ByVal SaveProperties As Boolean) As Boolean
        'Set up error function
        On Error GoTo Failed

        Dim grfThis As Graphic
        Set grfThis = theGraphic
        Set App = grfThis.Application
        If SaveProperties Then
            'OK button on property page was clicked
            'Form is still loaded
'            With frmSample
                'Need On Error statement for the case where you have
                'RRect Turbo Shape and ahother "shape" selected
'                On Error Resume Next

'            End With

' ------------------------------------------------------------------------
                  
                   ' Table-1
            grfThis.Properties("Image11") = Im11
            grfThis.Properties("Image12") = Im12
            grfThis.Properties("Image13") = Im13
            grfThis.Properties("Image14") = Im14
            grfThis.Properties("Image15") = Im15
            grfThis.Properties("Image16") = Im16
            grfThis.Properties("Image17") = Im17
            grfThis.Properties("Image18") = Im18
            
            grfThis.Properties("ImageFont11") = ImF11
            grfThis.Properties("ImageFont12") = ImF12
            grfThis.Properties("ImageFont13") = ImF13
            grfThis.Properties("ImageFont14") = ImF14
            grfThis.Properties("ImageFont15") = ImF15
            grfThis.Properties("ImageFont16") = ImF16
            grfThis.Properties("ImageFont17") = ImF17
            grfThis.Properties("ImageFont18") = ImF18
           
            grfThis.Properties("Text11") = Str11
            grfThis.Properties("Text12") = Str12
            grfThis.Properties("Text13") = Str13
            grfThis.Properties("Text14") = Str14
            grfThis.Properties("Text15") = Str15


                   ' Table-2
            grfThis.Properties("Image21") = Im21
            grfThis.Properties("Image22") = Im22
            grfThis.Properties("Image23") = Im23
            grfThis.Properties("Image24") = Im24
            grfThis.Properties("Image25") = Im25
            grfThis.Properties("Image26") = Im26
            grfThis.Properties("Image27") = Im27
            grfThis.Properties("Image28") = Im28
            
            grfThis.Properties("ImageFont21") = ImF21
            grfThis.Properties("ImageFont22") = ImF22
            grfThis.Properties("ImageFont23") = ImF23
            grfThis.Properties("ImageFont24") = ImF24
            grfThis.Properties("ImageFont25") = ImF25
            grfThis.Properties("ImageFont26") = ImF26
            grfThis.Properties("ImageFont27") = ImF27
            grfThis.Properties("ImageFont28") = ImF28

            grfThis.Properties("Text21") = Str21
            grfThis.Properties("Text22") = Str22
            grfThis.Properties("Text23") = Str23
            grfThis.Properties("Text24") = Str24
            grfThis.Properties("Text25") = Str25


                   ' Table-3
            grfThis.Properties("Image31") = Im31
            grfThis.Properties("ImageFont31") = ImF31
            grfThis.Properties("Text31") = Str31

                   ' Table-4
            grfThis.Properties("Text41") = Str41

                   ' Scale symbol
            grfThis.Properties("SymTxtHeight") = SymTxtHeight
                   
                   ' Text Font
            If frmSample.CheckFont.Value = 1 Then
                TextF = grfThis.Drawing.Properties("TextFont")
            End If
            grfThis.Properties("FontTxt") = TextF
                   
        Else
            'Property page is about to be opened
            'Make sure the form is loaded
'             Load frmSample
            Im11 = Chr(98)
            Im12 = Chr(110)
            Im13 = Chr(109)
            Im14 = ""
            Im15 = ""
            Im16 = ""
            Im17 = ""
            Im18 = ""
            ImF11 = "gdt.shx"
            ImF12 = "gdt.shx"
            ImF13 = "gdt.shx"
            Str11 = "0.000"
            Str12 = ""
            Str13 = "A"
            Str14 = "B"
            Str15 = "C"
            
            Im21 = ""
            Im22 = ""
            Im23 = ""
            Im24 = ""
            Im25 = ""
            Im26 = ""
            Im27 = ""
            Im28 = ""
            
            Str21 = ""
            Str22 = ""
            Str23 = ""
            Str24 = ""
            Str25 = ""

            Im31 = ""
            Str31 = ""
                   
            Str41 = ""
                
            SymTxtHeight = 0.3
            
            TextF = "Times New Roman"
                   ' Table-1
            On Error Resume Next
            Im11 = grfThis.Properties("Image11")
            Im12 = grfThis.Properties("Image12")
            Im13 = grfThis.Properties("Image13")
            Im14 = grfThis.Properties("Image14")
            Im15 = grfThis.Properties("Image15")
            Im16 = grfThis.Properties("Image16")
            Im17 = grfThis.Properties("Image17")
            Im18 = grfThis.Properties("Image18")
            
            ImF11 = grfThis.Properties("ImageFont11")
            ImF12 = grfThis.Properties("ImageFont12")
            ImF13 = grfThis.Properties("ImageFont13")
            ImF14 = grfThis.Properties("ImageFont14")
            ImF15 = grfThis.Properties("ImageFont15")
            ImF16 = grfThis.Properties("ImageFont16")
            ImF17 = grfThis.Properties("ImageFont17")
            ImF18 = grfThis.Properties("ImageFont18")
                                 
            Str11 = grfThis.Properties("Text11")
            Str12 = grfThis.Properties("Text12")
            Str13 = grfThis.Properties("Text13")
            Str14 = grfThis.Properties("Text14")
            Str15 = grfThis.Properties("Text15")


                   ' Table-2
            Im21 = grfThis.Properties("Image21")
            Im22 = grfThis.Properties("Image22")
            Im23 = grfThis.Properties("Image23")
            Im24 = grfThis.Properties("Image24")
            Im25 = grfThis.Properties("Image25")
            Im26 = grfThis.Properties("Image26")
            Im27 = grfThis.Properties("Image27")
            Im28 = grfThis.Properties("Image28")
            
            ImF21 = grfThis.Properties("ImageFont21")
            ImF22 = grfThis.Properties("ImageFont22")
            ImF23 = grfThis.Properties("ImageFont23")
            ImF24 = grfThis.Properties("ImageFont24")
            ImF25 = grfThis.Properties("ImageFont25")
            ImF26 = grfThis.Properties("ImageFont26")
            ImF27 = grfThis.Properties("ImageFont27")
            ImF28 = grfThis.Properties("ImageFont28")

            Str21 = grfThis.Properties("Text21")
            Str22 = grfThis.Properties("Text22")
            Str23 = grfThis.Properties("Text23")
            Str24 = grfThis.Properties("Text24")
            Str25 = grfThis.Properties("Text25")


                   ' Table-3
            Im31 = grfThis.Properties("Image31")
            ImF31 = grfThis.Properties("ImageFont31")
            Str31 = grfThis.Properties("Text31")

                   ' Table-4
            Str41 = grfThis.Properties("Text41")
            
                   ' Scale Symbol
            SymTxtHeight = grfThis.Properties("SymTxtHeight")
                
                    'Text Font
            TextF = grfThis.Properties("FontTxt")
                    
            Load frmSample
        End If
        
''        Set App = Nothing

        PageControls = True
        Exit Function

Failed:
        'For debugging purposes, report that an error occurred
        If Err.Number <> 0 Then
'            MsgBox "Error in PageControls: " & Err.Description
        End If
''        Set App = Nothing
        'Return false if an error occurred
        PageControls = False
End Function

Public Function PageDone(ByVal ThisRegenMethod As Object, Optional PageNumber As Variant)
        'Done with form
        Unload frmSample
        Set App = Nothing
End Function

Public Function PropertyPages(ByVal ThisRegenMethod As Object, Optional PageNumber As Variant) As Boolean
    With frmSample
        .Show vbModal
        PropertyPages = Not .DialogCanceled
    End With
End Function

Public Function Wizard(ByVal ThisRegenMethod As Object, Optional WizardNumber As Variant) As Boolean
    Wizard = False
End Function

'Called when vertex has been moved, or other geometry change
Public Function OnGeometryChanged(ByVal Graphic As Object, ByVal GeomID As Long, paramOld As Variant, paramNew As Variant)
    'Do nothing
    'Regen Graphic
End Function

'Called when vertex is moved, or other geometry change
Public Function OnGeometryChanging(ByVal Graphic As Object, ByVal GeomID As Long, paramOld As Variant, paramNew As Variant) As Boolean
    'OK to continue with change
    OnGeometryChanging = True
End Function

Public Function OnNewGraphic(ByVal theGraphic As Object, ByVal boolCopy As Boolean) As Boolean
    If boolCopy Then
        'Vertices are already added for us...
        OnNewGraphic = True
        Exit Function
    End If

    On Error GoTo Failed
'    Dim App As Object
    Dim grfThis As Graphic
    Set grfThis = theGraphic
'    Set App = grfThis.Application
'    strPath = App.Path & "\SDKBitMap\"
    'New Graphic being created
'Dim R#
'    R = CDbl(ScaleSymTxt) * R0
    'X, Y, Z, PenDown, Selectable, Snappable, Editable, Linkable
    'First Vertex is "lower left" corner
    grfThis.Vertices.Add 0#, 0#, 0#, False, True, False, True, False
    'Second Vertex is "lower right" corner
    grfThis.Vertices.Add 4#, 0#, 0#, False, True, False, True, False
    'Third Vertex is "upper right" corner
'    grfThis.Vertices.Add 4#, R, 0#, False, False, False, False, False
    'Fourth Vertex is "upper left" corner
'    grfThis.Vertices.Add 0#, R, 0#, False, False, False, False, False
     '5 Vertex is editable "lower left" corner
'    grfThis.Vertices.Add 0#, 0#, 0#, False, False, False, False, False
    '6 Vertex is editable "lower right" corner
'    grfThis.Vertices.Add 4#, 0#, 0#, False, False, False, False, False
    '7 Vertex is editable "upper right" corner
'    grfThis.Vertices.Add 4#, R, 0#, False, False, False, False, False
    '8 Vertex is editable "upper left" corner
'    grfThis.Vertices.Add 0#, R, 0#, False, False, False, False, False
   Len0 = 4#
   grfThis.Properties("LimitVertices") = 2
    OnNewGraphic = True
    Exit Function

Failed:
    'Return false on failure
    OnNewGraphic = False
End Function

'Function called whenever a copy of a graphic is being made
Public Function OnCopyGraphic(ByVal grfCopy As Object, ByVal grfSource As Object) As Boolean
    'Return false on failure
    OnCopyGraphic = True
End Function

'Notification function called after graphic property is saved
Public Function OnPropertyChanged(ByVal Graphic As Object, ByVal PropID As Long, _
        ValueOld As Variant, ValueNew As Variant)
    'Do nothing
End Function

'Notification function called when graphic property is saved
Public Function OnPropertyChanging(ByVal Graphic As Object, ByVal PropID As Long, _
        ValueOld As Variant, ValueNew As Variant) As Boolean
    'OK to proceed
    OnPropertyChanging = True
End Function

'Notification function called when graphic property is retrieved
Public Function OnPropertyGet(ByVal theGraphic As Object, ByVal PropID As Long)
    'Do nothing
End Function

'Called when we need to update our object
Public Function Regen(ByVal theGraphic As Object)
Dim Ver As Vertex
LLL:        'Setup error handler
        On Error GoTo Failed
        
        'Set up lock (prevent recursion)
        Dim LockCount&
        Dim grfThis As Graphic
        Set grfThis = theGraphic
'        grfThis.Properties("PenStyle") = "CONTINUOUS"
        ''On Error Resume Next
        ''grfThis.Properties("PenStyle") = "CONTINUOUS"
        ''Err.Clear
        ''On Error GoTo Failed

Dim NameUnit$
        NameUnit = grfThis.Drawing.Properties("LinearUnitName")
        If NameUnit = "mm" And grfThis.Properties("UnitName") = "in" Then
            grfThis.Properties("UnitName") = "mm"
            grfThis.Properties("SymTxtHeight") = grfThis.Properties("SymTxtHeight") * 25.4
        End If
If grfThis.Vertices.Count = 0 Then
    'First Vertex is "lower left" corner
    grfThis.Vertices.Add 0#, 0#, 0#, False, True, False, True, False
    'Second Vertex is "lower right" corner
    grfThis.Vertices.Add 4#, 0#, 0#, False, False, False, False, False
End If
R0 = 0.25

        LockCount& = grfThis.RegenLock
'MsgBox (grfThis.Drawing.Properties("LinearUnitName"))
   
        'Setup error handler (make sure lock is removed)
        On Error GoTo FailedLock
        If LockCount& = 0 Then
                   ' Table-1
            With grfThis
                Im11 = .Properties("Image11")
                Im12 = .Properties("Image12")
                Im13 = .Properties("Image13")
                Im14 = .Properties("Image14")
                Im15 = .Properties("Image15")
                Im16 = .Properties("Image16")
                Im17 = .Properties("Image17")
                Im18 = .Properties("Image18")
                ImF11 = .Properties("ImageFont11")
                ImF12 = .Properties("ImageFont12")
                ImF13 = .Properties("ImageFont13")
                ImF14 = .Properties("ImageFont14")
                ImF15 = .Properties("ImageFont15")
                ImF16 = .Properties("ImageFont16")
                ImF17 = .Properties("ImageFont17")
                ImF18 = .Properties("ImageFont18")
                Str11 = .Properties("Text11")
                Str12 = .Properties("Text12")
                Str13 = .Properties("Text13")
                Str14 = .Properties("Text14")
                Str15 = .Properties("Text15")
    
                       ' Table-2
                Im21 = .Properties("Image21")
                Im22 = .Properties("Image22")
                Im23 = .Properties("Image23")
                Im24 = .Properties("Image24")
                Im25 = .Properties("Image25")
                Im26 = .Properties("Image26")
                Im27 = .Properties("Image27")
                Im28 = .Properties("Image28")
                ImF21 = .Properties("ImageFont21")
                ImF22 = .Properties("ImageFont22")
                ImF23 = .Properties("ImageFont23")
                ImF24 = .Properties("ImageFont24")
                ImF25 = .Properties("ImageFont25")
                ImF26 = .Properties("ImageFont26")
                ImF27 = .Properties("ImageFont27")
                ImF28 = .Properties("ImageFont28")
                Str21 = .Properties("Text21")
                Str22 = .Properties("Text22")
                Str23 = .Properties("Text23")
                Str24 = .Properties("Text24")
                Str25 = .Properties("Text25")
    
                       ' Table-3
                Im31 = .Properties("Image31")
                ImF31 = .Properties("ImageFont31")
                Str31 = .Properties("Text31")
    
                       ' Table-4
                Str41 = .Properties("Text41")
                
                       ' Scale Symbol
                SymTxtHeight = .Properties("SymTxtHeight")
                    ' Text Font
                TextF = .Properties("FontTxt").Value
            End With
            
Dim Col As Long
        Col = grfThis.Properties("PenColor")

Dim R#
            R = SymTxtHeight * 0.625
            'Delete any previous cosmetic children
            grfThis.Graphics.Clear gfCosmetic

            Dim boolHandleMoved As Boolean
            'Add child Graphics
            Dim grfChild As Graphic
            Dim X0#, Y0#, X1#, Y1#, T#
Dim Z0#
            With grfThis.Vertices
                X0# = .Item(0).X
                Y0# = .Item(0).Y
                Z0# = .Item(0).Z
            End With
            
       Dim Salp#, Calp#, l#
            Dim X00#, Y00#, X01#, Y01#
            With grfThis.Vertices
                X00 = .Item(0).X
                Y00 = .Item(0).Y
                X01 = .Item(1).X
                Y01 = .Item(1).Y
                l = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
                Salp = (Y01 - Y00) / l
                Calp = (X01 - X00) / l
            End With
Dim alp#
            alp = Angle(Salp, Calp)
Dim i As Integer
Dim Xb#, Yb#
Dim Ymid#, Xb1#
Dim Symb As String
    
  If Mid(Im11, 1, 1) = Mid(Im21, 1, 1) And Im11 <> "" Then
    Ymid = Y0 - R
  Else
    Ymid = Y0
  End If
' -------------------------------------------------------------
 Dim D#
 D = 2# * R
 If Im11 <> "" Then
     
     Symb = Mid(Im11, 1, 1)
     If Mid(Im11, 1, 1) = Chr(116) Then
        Set grfChild = grfThis.Graphics.AddText(Symb, X0 + 0.08 * R, Ymid + 0.75 * D, Z0, 0.55 * D)
     Else
        Set grfChild = grfThis.Graphics.AddText(Symb, X0 + 0.1 * R, Ymid + 0.75 * D, Z0, 0.7 * D)
     End If
     With grfChild
        .Properties("TextFont") = ImF11 '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
    End With
 Else
   Xb = X0
   Yb = Y0
   GoTo L1
 End If
 
'------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add X0 + D, Y0, Z0
            .Add X0 + D, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'--------------------------------------------------------------

 Xb = X0 + D
 Yb = Y0
 Xb1 = Xb
L1:
 If Mid(Im12, 1, 1) = Chr(110) Then
    Symb = Mid(Im12, 1, 1)
    Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.15 * D, Yb + 0.75 * D, Z0, 0.75 * D)
     With grfChild
        .Properties("TextFont") = ImF12 '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
    End With

    Xb = Xb + D
    Yb = Y0
 End If
'---------------------------------------------------------------
' Text Fild - Text1=Str1
 If Len(Str11) > 0 Then
    If Im12 <> "" Then
        Set grfChild = grfThis.Graphics.AddText(Str11, Xb - 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
    Else
        Set grfChild = grfThis.Graphics.AddText(Str11, Xb + 0.2 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
    End If
     With grfChild
        .Properties("TextFont") = TextF '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X
    End With
    Yb = Y0
 End If
' ---------------------------------------------------------
 If Im13 <> "" Then
    Symb = Mid(Im13, 1, 1)
    Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
     With grfChild
        .Properties("TextFont") = ImF13 '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
    End With
    Xb = Xb + D
    Yb = Y0
 End If
'------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'--------------------------------------------------------------



' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
' Table-1  Datum-2
 If Mid(Im14, 1, 1) = Chr(110) Then
                
    Symb = Mid(Im14, 1, 1)
    Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.15 * D, Yb + 0.75 * D, Z0, 0.75 * D)
     With grfChild
        .Properties("TextFont") = ImF14 '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
    End With
    Xb = Xb + D
    Yb = Y0
 End If
'---------------------------------------------------------------
' Text Fild - Text1=Str1
 If Len(Str12) > 0 Then
    If Im14 <> "" Then
        Set grfChild = grfThis.Graphics.AddText(Str12, Xb - 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
    Else
        Set grfChild = grfThis.Graphics.AddText(Str12, Xb + 0.2 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
    End If
     With grfChild
        .Properties("TextFont") = TextF '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X
    End With
    Yb = Y0
 End If
' ---------------------------------------------------------
 If Im15 <> "" Then
    Symb = Mid(Im15, 1, 1)
    Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
     With grfChild
        .Properties("TextFont") = ImF15 '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
    End With
    Xb = Xb + D
    Yb = Y0
 End If
'------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'-------------------------------------------------------------

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

' Text Filds Text2=Str2  Text3=Str3  Text4=Str4
If Len(Str13) > 0 Then
    Set grfChild = grfThis.Graphics.AddText(Str13, Xb + 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
     With grfChild
        .Properties("TextFont") = TextF '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X + 0.3 * R
    End With
    Yb = Y0
    If Im16 <> "" Then
        Xb = Xb - 0.3 * R
        Symb = Mid(Im16, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
     With grfChild
        .Properties("TextFont") = ImF16 '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
    End With
        Xb = Xb + D
        Yb = Y0
    End If
'------------------------------------------------------
    
    Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'------------------------------------------------------

End If


If Len(Str14) > 0 Then
    Set grfChild = grfThis.Graphics.AddText(Str14, Xb + 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
     With grfChild
        .Properties("TextFont") = TextF '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X + 0.3 * R
    End With
    Yb = Y0
    If Im17 <> "" Then
        Xb = Xb - 0.3 * R
        Symb = Mid(Im17, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
         With grfChild
            .Properties("TextFont") = ImF17 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
' ------------------------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
' ------------------------------------------------------------------------
End If

If Len(Str15) > 0 Then
    Set grfChild = grfThis.Graphics.AddText(Str15, Xb + 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
     With grfChild
        .Properties("TextFont") = TextF '"gdt.shx"
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X + 0.3 * R
    End With
    Yb = Y0
    If Im18 <> "" Then
        Xb = Xb - 0.3 * R
        Symb = Mid(Im18, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
         With grfChild
            .Properties("TextFont") = ImF18 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
' ------------------------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
' ------------------------------------------------------------------------
End If
Dim Len1#
'MsgBox ("2222222x0=" & CStr(X0) & "  y0=" & CStr(Y0) & " z0=" & CStr(Z0))
Dim X10#, Y10#, X11#, Y11#, X12#, Y12#, X13#, Y13#
            With grfThis.Vertices
                .Item(0).X = X0
                .Item(0).Y = Y0
                .Item(0).Z = Z0
                .Item(1).X = Xb
                .Item(1).Y = Y0
                .Item(1).Z = Z0
'                X1 = .Item(1).X
'                Y1 = .Item(1).Y
                Len1 = Xb - X0
                X10 = .Item(0).X
                Y10 = .Item(0).Y
'                Z0 = .Item(0).Z
            End With
Dim dxW#, dyW#
            dxW = X0 - X10
            dyW = Y0 - Y10
            
            
'MsgBox ("333333x0=" & CStr(X0) & "  y0=" & CStr(Y0) & " z0=" & CStr(Z0))
'Dim X10#, Y10#, X11#, Y11#, X12#, Y12#, X13#, Y13#
Dim X14#, Y14#, X15#, Y15#, X16#, Y16#, X17#, Y17#
              With grfThis.Vertices
              '--------------------
                    X10 = X0
                    Y10 = Y0
                    X11 = Xb
                    Y11 = Y0
                    X12 = Xb
                    Y12 = Y0 + D
                    X13 = X0
                    Y13 = Y0 + D

              End With
              
                    ' Draw Box
    If Mid(Im11, 1, 1) = Mid(Im21, 1, 1) And Im11 <> "" Then
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb1, Y10, Z0
            .Add X11, Y11, Z0
        End With
                grfChild.Properties("PenColor") = Col
                        grfChild.Cosmetic = True
    Else
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add X10, Y10, Z0
            .Add X11, Y11, Z0
        End With
'MsgBox ("Child  x0=" & CStr(grfChild.Vertices.Item(0).X) & " y0=" & CStr(grfChild.Vertices.Item(0).Y))
        
                grfChild.Properties("PenColor") = Col
                        grfChild.Cosmetic = True
    End If
    Set grfChild = grfThis.Graphics.Add(11)
    With grfChild.Vertices
        .Add X11, Y11, Z0
        .Add X12, Y12, Z0
        .Add X13, Y13, Z0
        .Add X10, Y10, Z0
    End With
                grfChild.Properties("PenColor") = Col
                    grfChild.Cosmetic = True
              
' Table - 2 Begin Table - 2 Begin Table - 2 Begin Table - 2 Begin
' Table - 2 Begin Table - 2 Begin Table - 2 Begin Table - 2 Begin
' Table - 2 Begin Table - 2 Begin Table - 2 Begin Table - 2 Begin
              
 If Im21 <> "" Or Im22 <> "" Or Im23 <> "" Or Im24 <> "" Or Im25 <> "" Or Im26 <> "" Or Im27 <> "" Or Im28 <> "" Or Str21 <> "" Or Str22 <> "" Or Str23 <> "" Or Str24 <> "" Or Str25 <> "" Then
    Y0 = Y0 - D
    If Mid(Im11, 1, 1) = Mid(Im21, 1, 1) And Im11 <> "" Then
'        Xb = Xb1
        GoTo L12
    End If
    If Im21 <> "" Then
        Symb = Mid(Im21, 1, 1)
        If Mid(Im21, 1, 1) = Chr(116) Then
            Set grfChild = grfThis.Graphics.AddText(Symb, X0 + 0.08 * R, Y0 + 0.75 * D, Z0, 0.55 * D)
        Else
            Set grfChild = grfThis.Graphics.AddText(Symb, X0 + 0.1 * R, Y0 + 0.75 * D, Z0, 0.7 * D)
        End If
         With grfChild
            .Properties("TextFont") = ImF21 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
    End If
    If Im21 = "" Then
        Xb = X0
        Yb = Y0
        GoTo L11
    End If
L12:
'------------------------------------------------------
     Set grfChild = grfThis.Graphics.Add(11)
    With grfChild.Vertices
        .Add X0 + D, Y0, Z0
        .Add X0 + D, Y0 + D, Z0
    End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'--------------------------------------------------------------

    Xb = X0 + D
    Yb = Y0
L11:
    If Mid(Im22, 1, 1) = Chr(110) Then
        Symb = Mid(Im22, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.15 * D, Yb + 0.75 * D, Z0, 0.75 * D)
         With grfChild
            .Properties("TextFont") = ImF22 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
'---------------------------------------------------------------
' Text Fild - Text1=Str1
    If Len(Str21) > 0 Then
        If Im22 <> "" Then
            Set grfChild = grfThis.Graphics.AddText(Str21, Xb - 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
        Else
            Set grfChild = grfThis.Graphics.AddText(Str21, Xb + 0.2 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
        End If
         With grfChild
            .Properties("TextFont") = TextF '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
            Xb = .CalcBoundingBox.Max.X
        End With
        Yb = Y0
    End If
' ---------------------------------------------------------
    If Im23 <> "" Then
        Symb = Mid(Im23, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
         With grfChild
            .Properties("TextFont") = ImF23 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
'------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'--------------------------------------------------------------



' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
' Table-1  Datum-2
    If Mid(Im24, 1, 1) = Chr(110) Then
        Symb = Mid(Im24, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.15 * D, Yb + 0.75 * D, Z0, 0.75 * D)
         With grfChild
            .Properties("TextFont") = ImF24 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
'---------------------------------------------------------------
' Text Fild - Text1=Str1
    If Len(Str22) > 0 Then
        If Im24 <> "" Then
            Set grfChild = grfThis.Graphics.AddText(Str22, Xb - 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
        Else
            Set grfChild = grfThis.Graphics.AddText(Str22, Xb + 0.2 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
        End If
         With grfChild
            .Properties("TextFont") = TextF '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
            Xb = .CalcBoundingBox.Max.X
       End With
        Yb = Y0
    End If
' ---------------------------------------------------------
    If Im25 <> "" Then
        Symb = Mid(Im25, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
         With grfChild
            .Properties("TextFont") = ImF25 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
'------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
'-------------------------------------------------------------

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


' Text Filds Text2=Str2  Text3=Str3  Text4=Str4
    If Len(Str23) > 0 Then
        Set grfChild = grfThis.Graphics.AddText(Str23, Xb + 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D)
         With grfChild
            .Properties("TextFont") = TextF '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
            Xb = .CalcBoundingBox.Max.X + 0.3 * R
        End With
        Yb = Y0
        If Im26 <> "" Then
            Xb = Xb - 0.3 * R
            Symb = Mid(Im26, 1, 1)
           Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
             With grfChild
                .Properties("TextFont") = ImF26 '"gdt.shx"
                .Properties("TextStyle") = 0
                .Properties("PenColor") = Col
                .Cosmetic = True
            End With
            Xb = Xb + D
            Yb = Y0
        End If
' --------------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                   grfChild.Cosmetic = True
' --------------------------------------------------------------------------
    End If


    If Len(Str24) > 0 Then
        Set grfChild = grfThis.Graphics.AddText(Str24, Xb + 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
         With grfChild
            .Properties("TextFont") = TextF
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
            Xb = .CalcBoundingBox.Max.X + 0.3 * R
        End With
        Yb = Y0
        If Im27 <> "" Then
            Xb = Xb - 0.3 * R
            Symb = Mid(Im27, 1, 1)
            Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
             With grfChild
                .Properties("TextFont") = ImF27 '"gdt.shx"
                .Properties("TextStyle") = 0
                .Properties("PenColor") = Col
                .Cosmetic = True
            End With
            Xb = Xb + D
            Yb = Y0
        End If
'---------------------------------------------------------------
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, 0
            .Add Xb, Y0 + D, 0
        End With
                grfChild.Properties("PenColor") = Col
                    grfChild.Cosmetic = True
'---------------------------------------------------------------
    End If

    If Len(Str25) > 0 Then
        Set grfChild = grfThis.Graphics.AddText(Str25, Xb + 0.3 * R, Yb + 0.9 * D, Z0, 0.8 * D, 0)
         With grfChild
            .Properties("TextFont") = TextF
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
            Xb = .CalcBoundingBox.Max.X + 0.3 * R
        End With
        Yb = Y0
        If Im28 <> "" Then
            Xb = Xb - 0.3 * R
            Symb = Mid(Im28, 1, 1)
            Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.1 * R, Yb + 0.75 * D, Z0, 0.7 * D)
             With grfChild
                .Properties("TextFont") = ImF28 '"gdt.shx"
                .Properties("TextStyle") = 0
                .Properties("PenColor") = Col
                .Cosmetic = True
            End With
            Xb = Xb + D
            Yb = Y0
        End If
    
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb, Y0, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                    grfChild.Cosmetic = True
    End If
    
                            ' Draw Box

    Set grfChild = grfThis.Graphics.Add(11)
    With grfChild.Vertices
        .Add X0, Y0 + D, Z0
        .Add X0, Y0, Z0
        .Add Xb, Y0, Z0
    End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True

    If Mid(Im11, 1, 1) = Mid(Im21, 1, 1) And Im11 <> "" Then
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add Xb1, Y0 + D, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                    grfChild.Cosmetic = True
    Else
        Set grfChild = grfThis.Graphics.Add(11)
        With grfChild.Vertices
            .Add X0, Y0 + D, Z0
            .Add Xb, Y0 + D, Z0
        End With
                grfChild.Properties("PenColor") = Col
                    grfChild.Cosmetic = True
    End If
 End If
              
' Table - 2 End  Table - 2 End  Table - 2 End  Table - 2 End  Table - 2 End
' Table - 2 End  Table - 2 End  Table - 2 End  Table - 2 End  Table - 2 End
' Table - 2 End  Table - 2 End  Table - 2 End  Table - 2 End  Table - 2 End
              
              
' Table - 3 Begin Table - 3 Begin Table - 3 Begin Table - 3 Begin
' Table - 3 Begin Table - 3 Begin Table - 3 Begin Table - 3 Begin
' Table - 3 Begin Table - 3 Begin Table - 3 Begin Table - 3 Begin
              
              
 If Len(Str31) > 0 Then
    Y0 = Y0 - D
 
    Set grfChild = grfThis.Graphics.AddText(Str31, X0 + 0.3 * R, Y0 + 0.9 * D, Z0, 0.8 * D)
    With grfChild
        .Properties("TextFont") = TextF
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X + 0.3 * R
    End With
    Yb = Y0
    Xb = Xb - 0.5 * R
    If Mid(Im31, 1, 1) = Chr(112) Then
        Symb = Mid(Im31, 1, 1)
        Set grfChild = grfThis.Graphics.AddText(Symb, Xb + 0.2 * R, Yb + 0.75 * D, Z0, 0.7 * D)
         With grfChild
            .Properties("TextFont") = ImF31 '"gdt.shx"
            .Properties("TextStyle") = 0
            .Properties("PenColor") = Col
            .Cosmetic = True
        End With
        Xb = Xb + D
        Yb = Y0
    End If
    If Im31 = "" Then
        Xb = Xb + 0.5 * R
    End If
                                ' Draw Box
                
    Set grfChild = grfThis.Graphics.Add(11)
    With grfChild.Vertices
        .Add X0, Y0, Z0
        .Add Xb, Y0, Z0
        .Add Xb, Y0 + D, Z0
        .Add X0, Y0 + D, Z0
        .Add X0, Y0, Z0
    End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True
 End If
    
        
' Table - 3 End  Table - 3 End  Table - 3 End  Table - 3 End  Table - 3 End
' Table - 3 End  Table - 3 End  Table - 3 End  Table - 3 End  Table - 3 End
              
              
' Table - 4 Begin Table - 4 Begin Table - 4 Begin Table - 4 Begin
' Table - 4 Begin Table - 4 Begin Table - 4 Begin Table - 4 Begin
              
              
 If Len(Str41) > 0 Then
    Y0 = Y0 - D
 
    Set grfChild = grfThis.Graphics.AddText(Str41, X0 + 0.3 * R, Y0 + 0.9 * D, Z0, 0.8 * D, 0, , , 1)
    With grfChild
        .Properties("TextFont") = TextF
        .Properties("TextStyle") = 0
        .Properties("PenColor") = Col
        .Cosmetic = True
        Xb = .CalcBoundingBox.Max.X + 0.2 * R
    End With
    
                             ' Draw Box
                             
    Set grfChild = grfThis.Graphics.Add(11)
    With grfChild.Vertices
        .Add X0, Y0, Z0
        .Add Xb, Y0, Z0
        .Add Xb, Y0 + D, Z0
        .Add X0, Y0 + D, Z0
        .Add X0, Y0, Z0
    End With
                grfChild.Properties("PenColor") = Col
                grfChild.Cosmetic = True

 End If

' Table - 4 End  Table - 4 End  Table - 4 End  Table - 4 End  Table - 4 End
' Table - 4 End  Table - 4 End  Table - 4 End  Table - 4 End  Table - 4 End
        X0 = grfThis.Vertices.Item(0).X
        Y0 = grfThis.Vertices.Item(0).Y
        X1 = grfThis.Vertices.Item(1).X
        Y1 = grfThis.Vertices.Item(1).Y
 Dim Z1#


Dim CountCosm As Long, iCosm As Long, nV As Long, iV As Long, xi#, yi#, xir#, yir#
                xi = X1 - X0
                yi = Y1 - Y0
                xir = X0 + xi * Calp - yi * Salp
                yir = Y0 + xi * Salp + yi * Calp
                grfThis.Vertices.Item(1).X = xir
                grfThis.Vertices.Item(1).Y = yir
        
'MsgBox ("x00=" & CStr(X00) & "  y00=" & CStr(Y00)) ' & " z0=" & CStr((Z0 + z1) / 2))
        CountCosm = grfThis.Graphics.Count
        For iCosm = 0 To CountCosm - 1
            Set grfChild = grfThis.Graphics.Item(iCosm)
            If iCosm <> 0 Then
                On Error Resume Next
                grfChild.Properties("PenStyle") = "CONTINUOUS"
                grfChild.Update
                grfChild.Properties("Thickness") = 0
            End If
            With grfChild.Vertices
                 nV = .Count
                 For iV = 0 To nV - 1
                     xi = .Item(iV).X - X0
                     yi = .Item(iV).Y - Y0
                     xir = X0 + xi * Calp - yi * Salp
                     yir = Y0 + xi * Salp + yi * Calp
                     .Item(iV).X = xir
                     .Item(iV).Y = yir
                Next iV
            End With
        Next iCosm
            'Add visible child Graphics
        End If

        grfThis.RegenUnlock
        
        Exit Function

FailedLock:
        'Remove lock
        grfThis.RegenUnlock

Failed:
        'grfThis.Application.PopVertexDefaults
If Err.Description = "Division by zero" Then GoTo LLL
        If Err.Number <> 0 Then
            'MsgBox "Regen error: " & Err.Description
        End If
End Function

Public Function Draw(ByVal grfThis As Object, ByVal view As Object, Optional mat As Variant) As Boolean
    'Return True if we did the redraw (no further processing necessary, no children will be drawn).
    'Since this is just a test, we return False to let TurboCAD do the drawing operation.
    Draw = False
End Function

Private Function Angle(sinb As Double, cosb As Double) As Double

        If Abs(cosb) < 0.0001 Then
            If sinb > 0 Then
                Angle = pi / 2
            Else
                Angle = 3 * pi / 2
            End If
        Else
            If sinb >= 0 And cosb > 0 Then Angle = Atn(sinb / cosb)
            If sinb >= 0 And cosb < 0 Then Angle = pi + Atn(sinb / cosb)
            If sinb < 0 And cosb < 0 Then Angle = pi + Atn(sinb / cosb)
            If sinb < 0 And cosb > 0 Then Angle = 2 * pi + Atn(sinb / cosb)
        End If
End Function

